<template>
  <div class="app-container">
    <div class="filter-container">
      <el-form :inline="true" :model="formModel">
        <el-form-item class="no-warn-item" label="整车物料号:" prop="materialNo">
          <el-input v-model="formModel.materialNo" disabled>
            <el-button slot="append" type="primary" icon="el-icon-search" @click="queryMaterialData"></el-button>
          </el-input>
        </el-form-item>
        <el-form-item class="no-warn-item" label="工程整车号:" prop="vehicleNo">
          <el-input
            v-model="formModel.vehicleNo"
            class="filter-item "
            clearable
          />
        </el-form-item>
        <el-row class="submit-area">
          <el-col :span="24">
            <el-button type="primary" plain @click="queryList">查询</el-button>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <hey-table ref="table" @row-click="handleRowClick" :columns="columns" :is-radio="true">

    </hey-table>
    <el-row class="submit-area">
      <el-col :span="24">
        <el-button @click="closeDialog">取消</el-button>
        <el-button type="primary" @click="handleSubmit()">确定</el-button>
      </el-col>
    </el-row>
    <el-dialog
      v-dialogDrag
      v-if="showMaterialData"
      :close-on-click-modal="false"
      title="物料主数据"
      :visible.sync="showMaterialData"
      width="90%"
      append-to-body
    >
      <material-data-dialog :edit-data="editData" @queryMaterialDataSuc="queryMaterialDataSuc" />
    </el-dialog>
  </div>
</template>

<script>
  export default {
    name: 'MaterialVehicleDialog',
    components: {
      MaterialDataDialog: () => import('@/views/dialog/material-data-dialog')
    },
    props: {

    },
    data() {
      return {
        chooseData:{},
        editData:{},
        showMaterialData:false,
        formModel: {
          materialNo: '',
          vehicleNo: '',
          isDelete: '0'
        },
        columns: [
          { title: '整车物料号', key: 'materialNo'},
          { title: '车型', key: 'productTypeKey',clcd:'key_product_type'},
          { title: '工程整车号', key: 'vehicleNo'},
          { title: '工程整车描述', key: 'vehicleDesc'},
          { title: '创建时间', key: 'createTime' },
          { title: '创建人', key: 'createUsername' },
          { title: '最后修改时间', key: 'lastUpdateTime'},
          { title: '最后修改人', key: 'lastUpdateUsername' },
        ],
        rules: {
        }
      }
    },
    computed: {

    },
    mounted() {

    },
    methods: {
      queryMaterialData(){
        this.editData.materialTypeKey = 'car'
        this.showMaterialData = true
      },
      queryMaterialDataSuc(data){
        this.formModel.materialNo = data.materialNo
      },
      handleSubmit() {
        if(Object.keys(this.chooseData).length==0){
          this.$warn('请单击选中一条数据!')
          return false
        }
        this.$emit('queryVehicleNoSuc', this.chooseData)
        this.closeDialog()
      },
      handleRowClick(row){
        this.chooseData = row
      },
      queryList() {
        this.$refs.table.query('/trBasMaterialVehicle/queryTrBasMaterialVehicle', this.formModel, '', false)
      },
      closeDialog() {
        this.$parent.$emit('update:visible', false)
      }
    }
  }
</script>

<style lang="scss" scoped>

</style>
